x = int(input())


def baoli(x):
    cnt = 0
    for y in range(1, x):
        z = x ^ y
        if x + y > z and x + z > y and y + z > x:
            cnt += 1
    return cnt


def build(x):
    cnt_1 = 0
    length = 0
    while x:
        if x & 1:
            cnt_1 += 1
        length += 1
        x >>= 1
    # 先计算对应位置为0的方案数有多少种 再使用容斥原理计算
    ways = 1 << (length - cnt_1)
    # 使用总方案数减去
    w = (1 << length) - ways
    return w - 1


print(build(x))
print(baoli(x))
